<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="format-detection" content="telephone=no">
    <title>余额提现</title>
    <link rel="stylesheet" href="${ctx}/static/plug/frozenui-1.3.0/css/frozen.css" media="all">
    <link rel="stylesheet" href="${ctx}/static/css/user/register.css" media="all">
    <style type="text/css">
        .content {
            padding-top: 10px;
            padding-left: 20px;
            padding-right: 20px
        }

        .recharge-content {
            width: 100%;
            margin-top: 10px;
            padding-bottom: 20px;
            padding-top: 10px;
            background-color: #248dc2;
            color: white;
            border-radius: 5px
        }

        .unselected-content {
            width: 100%;
            margin-top: 10px;
            padding-bottom: 20px;
            padding-top: 10px;
            background-color: #f8f8f8;
            color: #25282e;
            border-radius: 5px;
            border: 1px solid #25282e
        }

        .charge_button {
            font-size: 16px;
            border: 0px #FFFFFF solid;
            text-align: center;
            padding: 0px;
            vertical-align: middle;
            line-height: 20px;
            margin: 0px;
            Width: 100%;
        }
    </style>
</head>
<body>

<section class="ui-container">
    <div class="ui-flex  ui-flex-ver ui-flex-pack-center content">
        <div style="margin-top: 50px; margin-left: 10px">
            <h1>
                钱包总余额:&nbsp;&nbsp;<label style="color: #25282e">￥<fmt:formatNumber type="number"
                                                                                   value="${userInfo.money / 10 }"
                                                                                   pattern="0.00"
                                                                                   maxFractionDigits="2"/></label>
            </h1>
        </div>
        <div style="margin-top: 0px; margin-left: 10px">
            <h1>可提现余额:</h1>
        </div>
        <div style="margin: 0 auto; text-align: center">
            <h1 style="font-size: 40px; color: #469fe3">
                ￥
                <fmt:formatNumber type="number" value="${userInfo.money / 10 }" pattern="0.00" maxFractionDigits="2"/>
            </h1>
        </div>
        <div class="ui-notice-btn" style="text-align: center; padding-top: 80px">
            <button id="btnTx" class="ui-btn-lg  ui-btn-primary charge_button" style="border-radius: 5px;"
                    data="${userInfo.money}">确认提现
            </button>
            <p class="title" style="font-size: 14px">
                赠券不能提现,详细&nbsp;<font color="#0baae4"><a href="${ctx}/cashRule.jsp" >查看提现规则</a></font>
            </p>
            <p class="title" style="font-size: 14px; padding-top: 2px">
                提现后会在48小时内返回微信账户</font>
            </p>
        </div>
    </div>
</section>
<section id="dialog">
    <div class="demo-block">
        <div class="ui-dialog ">
            <div class="ui-dialog-cnt" style="width:90%">
                <header class="ui-dialog-hd ui-border-b">
                    <h1 class="ui-icon-info"></h1>
                </header>
                <div class="ui-dialog-bd">
                    <div>提现会清除账户内所有的赠券，请确认是否要提现？</div>
                </div>
                <div class="ui-dialog-ft">
                    <button type="button" id="btnWithdraw" data-role="button">确定</button>
                    <button type="button" id="btnCancel" data-role="button">取消</button>
                </div>
            </div>
        </div>
    </div>
</section>
</body>
<script src="${ctx}/static/plug/frozenui-1.3.0/lib/zepto.min.js"></script>
<script src="${ctx}/static/plug/frozenui-1.3.0/js/frozen.js"></script>
<script src="${ctx}/static/plug/frozenui-1.3.0/js/component/dialog.js"></script>
<script>
    var paramObj = {
        "withdrawCashParams": "${withdrawCashParams}",
        "myMoneyParams": "${myMoneyParams}"
    };
    var canSubmit = true;
    $(function () {
		$("#btnTx").click(function() {
			$(".ui-dialog").addClass("show");
		});

		$("#btnWithdraw").click(function() {
			$(".ui-dialog").removeClass("show");
			var money = $(this).attr("data");
			if (money <= 0) {
				showTips("warn", "余额不足，无法提现！");
			} else {
				var paraObj = {
					"params" : paramObj.withdrawCashParams
				};
				if (canSubmit) {
					canSubmit = false;
					$.post("${action}", paraObj, function(data) {
						canSubmit = true;
						if (data.result) {
							showTips("warn", "提现成功！");
							window.location.href = "${action}?params=" + paramObj.myMoneyParams;
						} else {
							showTips("warn", "提现失败，请联系管理员！");
						}
					});
				}
			}
		});
		
		$("#btnCancel").click(function() {
			$(".ui-dialog").removeClass("show");
		});
	});
</script>
</html>
